package com.ruoyi.performancesys.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.performancesys.vo.PerformanceVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.performancesys.domain.SalaryPerformance;
import com.ruoyi.performancesys.service.ISalaryPerformanceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 绩效管理Controller
 * 
 * @author ruoyi
 * @date 2024-08-12
 */
@RestController
@RequestMapping("/performancesys/performance")
public class SalaryPerformanceController extends BaseController
{
    @Autowired
    private ISalaryPerformanceService salaryPerformanceService;

    /**
     * 查询绩效管理列表
     */
    @PreAuthorize("@ss.hasPermi('performancesys:performance:list')")
    @GetMapping("/list")
    public TableDataInfo list(SalaryPerformance salaryPerformance)
    {
        startPage();
        List<SalaryPerformance> list = salaryPerformanceService.selectSalaryPerformanceList(salaryPerformance);
        return getDataTable(list);
    }

    /**
     * 导出绩效管理列表
     */
    @PreAuthorize("@ss.hasPermi('performancesys:performance:export')")
    @Log(title = "绩效管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SalaryPerformance salaryPerformance)
    {
        List<SalaryPerformance> list = salaryPerformanceService.selectSalaryPerformanceList(salaryPerformance);
        ExcelUtil<SalaryPerformance> util = new ExcelUtil<SalaryPerformance>(SalaryPerformance.class);
        util.exportExcel(response, list, "绩效管理数据");
    }

    /**
     * 获取绩效管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('performancesys:performance:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(salaryPerformanceService.selectSalaryPerformanceById(id));
    }

    /**
     * 新增绩效管理
     */
    @PreAuthorize("@ss.hasPermi('performancesys:performance:add')")
    @Log(title = "绩效管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PerformanceVo performanceVo)
    {
        return toAjax(salaryPerformanceService.insertSalaryPerformance(performanceVo));
    }

    /**
     * 修改绩效管理
     */
    @PreAuthorize("@ss.hasPermi('performancesys:performance:edit')")
    @Log(title = "绩效管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SalaryPerformance salaryPerformance)
    {
        return toAjax(salaryPerformanceService.updateSalaryPerformance(salaryPerformance));
    }

    /**
     * 删除绩效管理
     */
    @PreAuthorize("@ss.hasPermi('performancesys:performance:remove')")
    @Log(title = "绩效管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(salaryPerformanceService.deleteSalaryPerformanceByIds(ids));
    }
}
